home *** CD-ROM | disk | FTP | other *** search
- Path: news.midusa.net!wpmills
- From: wpmills@midusa.net (W. Paul Mills)
- Newsgroups: comp.lang.c
- Subject: Re: goto
- Date: 14 Mar 96 16:17:33 GMT
- Organization: Netspace
- Message-ID: <wpmills.826820253@wpmills>
- References: <Pine.OSF.3.91.960313102715.10701D-100000@io.UWinnipeg.ca>
- NNTP-Posting-Host: node2.topeka.midusa.net
-
- Bill Simpson <wsimpson@uwinnipeg.ca> writes:
-
- >There was a goto thread lately, and my problem is to state this algorithm
- >cleanly without gotos (which I think is easy, but my attempts have been
- >failures).
-
- >0. x=0;
- >1. x+=erand(maxmean);
- >2. if (urand2()>rate(x)/maxrate)
- > goto step 1
- >3. if (x<=XMAX)
- > {
- > setdot(x,y,z);
- > goto step 1
- > }
- >explanation:
- >erand(mean) returns exponential double random number with given mean
- >urand2() returns uniform double random number between 0 & 1
- >rate(). well the rate of the Poisson process varies with x
-
- x = 0
-
- do {
- x += erand(maxmean);
- if (urand2() > rate(x) / maxrate) continue;
- setdot(x, y, z);
- } while ( x < XMAX);
- --
- -------------------------------------------------------------------
- : W. Paul Mills : Compiler Bug: Any action of the compiler :
- : Topeka, Kansas, U.S.A. : that I did not intend. It :
- : wpmills@midusa.net : couldn't be my code? :
- : wpmills@tyrell.net : ---------------------------------------- :
- : paulmills@bix.com : Linux: The Operating system of a :
- : paulmills@aol.com : GNU Generation. :
- : PAULMILLS@delphi.com : ---------------------------------------- :
- : compuserve 70023,1750 : #define MY_TRUE_LOVE computer :
- -------------------------------------------------------------------
-